/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { message } from 'antd';
import { getHistoryList } from '@/services/delivery';

export default {
  namespace: 'history',
  state: {
    historyList: {},
  },

  effects: {
    *getHistoryList({ payload }, { call, put, select }) {
      const { code, data } = yield call(getHistoryList, payload);
      if (code == 0) {
        yield put({
          type: 'save',
          payload: {
            historyList: {
              list: data.list,
              pagination: {
                total: data.count,
                pageSize: payload.size || 10,
                current: data.page,
              },
            },
          },
        });
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
